﻿using System;

namespace Delphi.Mimir.Data.Entities.Final {
    public class FinancialStatement {
        public int FinancialStatementId { set; get; }
        public int SymbolId { set; get; }
        public Symbol Symbol { set; get; }
        public int FrequencyId { set; get; }
        public Frequency Frequency { set; get; }
        public DateTime Date { set; get; }

        // Income Statement
        public long TotalRevenue { set; get; }
        public long CostOfGoodsSold { set; get; }
        public long GrossProfit {
            get {
                return TotalRevenue - CostOfGoodsSold;
            }
        }
        public long ResearchAndDevelopment { set; get; }
        public long SellingGeneralAndAdministrative { set; get; }
        public long NonRecurringOperatingExpense { set; get; }
        public long OtherOperatingExpense { set; get; }
        public long TotalOperatingExpense {
            get {
                return ResearchAndDevelopment + SellingGeneralAndAdministrative + NonRecurringOperatingExpense + OtherOperatingExpense;
            }
        }
        public long OperatingIncomeOrLoss {
            get {
                return GrossProfit - TotalOperatingExpense;
            }
        }
        public long TotalOtherIncomeOrExpensesNet { set; get; }
        public long EarningsBeforeInterestOrTaxes {
            get {
                return OperatingIncomeOrLoss - TotalOtherIncomeOrExpensesNet;
            }
        }
        public long InterestExpenses { set; get; }
        public long EarningsBeforeTaxes {
            get {
                return EarningsBeforeInterestOrTaxes - InterestExpenses;
            }
        }
        public long IncomeTaxExpenses { set; get; }
        public long MinorityInterest { set; get; }
        public long NetIncomeFromContinuingOps {
            get {
                return EarningsBeforeTaxes - IncomeTaxExpenses - MinorityInterest;
            }
        }
        public long DiscontinuedOperations { set; get; }
        public long ExtraordinaryItems { set; get; }
        public long EffectOfAccountingChanges { set; get; }
        public long OtherNonRecurringItems { set; get; }
        public long NetIncome {
            get {
                return NetIncomeFromContinuingOps + DiscontinuedOperations + ExtraordinaryItems + EffectOfAccountingChanges + OtherNonRecurringItems;
            }
        }
        public long PreferredStockAndOtherAdjustments { set; get; }
        public long NetIncomeAppicableToCommonShares {
            get {
                return NetIncome + PreferredStockAndOtherAdjustments;
            }
        }
        public bool HasIncomeStatementQualityIssues { set; get; }
        public long NetIncomeQualityAdjustment { set; get; }

        // Balance Sheet
        public long CashAndCashEquivalents { set; get; }
        public long ShortTermInvestments { set; get; }
        public long NetReceivables { set; get; }
        public long Inventory { set; get; }
        public long OtherCurrentAssets { set; get; }
        public long TotalCurrentAssets {
            get {
                return CashAndCashEquivalents + ShortTermInvestments + NetReceivables + Inventory + OtherCurrentAssets;
            }
        }
        public long LongTermInvestments { set; get; }
        public long PropertyPlantAndEquipment { set; get; }
        public long Goodwill { set; get; }
        public long IntangibleAssets { set; get; }
        public long AccumulatedAmortization { set; get; }
        public long OtherNonCurrentAssets { set; get; }
        public long DeferredLongTermAssetCharges { set; get; }
        public long TotalNonCurrentAssets {
            get {
                return LongTermInvestments + PropertyPlantAndEquipment + Goodwill + IntangibleAssets + AccumulatedAmortization
                    + OtherNonCurrentAssets + DeferredLongTermAssetCharges;
            }
        }
        public long TotalAssets {
            get {
                return TotalCurrentAssets + TotalNonCurrentAssets;
            }
        }
        public long AccountsPayable { set; get; }
        public long ShortAndCurrentLongTermDebt { set; get; }
        public long OtherCurrentLiabilities { set; get; }
        public long TotalCurrentLiabilities {
            get {
                return AccountsPayable + ShortAndCurrentLongTermDebt + OtherCurrentLiabilities;
            }
        }
        public long LongTermDebt { set; get; }
        public long OtherNonCurrentLiabilities { set; get; }
        public long DeferredLongTermLiabilitiesCharges { set; get; }
        public long AccumulatedMinorityInterest { set; get; }
        public long NegativeGoodwill { set; get; }
        public long TotalNonCurrentLiabilities {
            get {
                return LongTermDebt + OtherNonCurrentLiabilities + DeferredLongTermLiabilitiesCharges
                    + AccumulatedMinorityInterest + NegativeGoodwill;
            }
        }
        public long TotalLiabilities {
            get {
                return TotalCurrentLiabilities + TotalNonCurrentLiabilities;
            }
        }
        public long MiscStocksOptionsWarrants { set; get; }
        public long RedeemablePreferredStock { set; get; }
        public long PreferredStock { set; get; }
        public long CommonStock { set; get; }
        public long RetainedEarnings { set; get; }
        public long TreasuryStock { set; get; }
        public long CapitalSurplus { set; get; }
        public long OtherStockholderEquity { set; get; }
        public long TotalStockholderEquity {
            get {
                return MiscStocksOptionsWarrants + RedeemablePreferredStock + PreferredStock + CommonStock
                    + RetainedEarnings + TreasuryStock + CapitalSurplus + OtherStockholderEquity;
            }
        }
        public long NetTangibleAssets { set; get; }

        // Cash Flow
        public long Depreciation { set; get; }
        public long AdjustmentsToNetIncome { set; get; }
        public long ChangesInAccountReceivables { set; get; }
        public long ChangesInLiabilities { set; get; }
        public long ChangesInInventories { set; get; }
        public long ChangesInOtherOperatingActivities { set; get; }
        public long TotalCashFlowFromOperatingActivities {
            get {
                return NetIncome + Depreciation + AdjustmentsToNetIncome + ChangesInAccountReceivables
                    + ChangesInLiabilities + ChangesInInventories + ChangesInOtherOperatingActivities;
            }
        }
        public long CapitalExpenditure { set; get; }
        public long Investments { set; get; }
        public long OtherCashFlowFromInvestingActivities { set; get; }
        public long TotalCashFlowFromInvestingActivities {
            get {
                return CapitalExpenditure + Investments + OtherCashFlowFromInvestingActivities;
            }
        }
        public long DividendsPaid { set; get; }
        public long SalePurchaseOfStock { set; get; }
        public long NetBorrowings { set; get; }
        public long OtherCashFlowFromFinancingActivities { set; get; }
        public long TotalCashFlowFromFinancingActivities {
            get {
                return DividendsPaid + SalePurchaseOfStock + NetBorrowings + OtherCashFlowFromFinancingActivities;
            }
        }
        public long EffectOfExchangeRateChanges { set; get; }
        public long ChangeInCashAndCashEquivalents { set; get; }
    }
}
